package com.olah.ws.dao;

import com.olah.common.entity.po.ws.dto.chat.PrivateMsg;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface PrivateMsgDao {

    @Insert("INSERT INTO message_private(ch_chat_id, ch_sender, ch_receiver, ch_msg, ch_time) VALUES(#{chatId}, #{sender}, #{receiver}, #{msg}, #{time})")
    void sendToUser(PrivateMsg userMsg);

    List<PrivateMsg> readAll(Map<String, Object> map);

    @Update("UPDATE message_private SET ch_read = 1 WHERE ch_chat_id = #{chatId} AND ch_read = 0")
    void doRead(@Param("chatId") String chatId);

}
